<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"PJ-7-2");
// -- get customer
mysql_select_db($database_con_gl, $con_gl);
$query_kontak = "SELECT id, nama, type, tcustomer FROM gl_kontak where gl_kontak.type ='Customer' ORDER BY type, nama ASC";
$kontak = mysql_query($query_kontak, $con_gl) or die(mysql_error());
$row_kontak = mysql_fetch_assoc($kontak);
$totalRows_kontak = mysql_num_rows($kontak);
// get paket
mysql_select_db($database_con_gl, $con_gl);
$query_kelom = "SELECT id, kelompok FROM gl_kelompok where jual=1 AND jenis=2 ORDER BY kelompok ASC";
$kelom = mysql_query($query_kelom, $con_gl) or die(mysql_error());
$row_kelom = mysql_fetch_assoc($kelom);
$totalRows_kelom = mysql_num_rows($kelom);
// --- lokasi kantor
mysql_select_db($database_con_gl, $con_gl);
$query_gudang = "SELECT id, gudang FROM gl_gudang";
if(!strstr($_SESSION[akses],'A-1-4')) {
	$query_gudang .= " where id='$_SESSION[lokasi]'";
}
$query_gudang .=" ORDER BY gudang ASC";
$gudang = mysql_query($query_gudang, $con_gl) or die(mysql_error());
$row_gudang = mysql_fetch_assoc($gudang);
$totalRows_gudang = mysql_num_rows($gudang);
// default akun
mysql_select_db($database_con_gl, $con_gl);
$query_def_ak = "SELECT gl_company.a_piu, gl_company.a_kas, gl_company.a_beb, gl_company.a_paj FROM gl_company";
$def_ak = mysql_query($query_def_ak, $con_gl) or die(mysql_error());
$row_def_ak = mysql_fetch_assoc($def_ak);
$totalRows_def_ak = mysql_num_rows($def_ak);
// salesman
mysql_select_db($database_con_gl, $con_gl);
$query_salesmen = "SELECT gl_kontak.id, gl_kontak.nama FROM gl_kontak WHERE gl_kontak.type='Karyawan' AND tkaryawan='sales' order by nama";
$salesmen = mysql_query($query_salesmen, $con_gl) or die(mysql_error());
$row_salesmen = mysql_fetch_assoc($salesmen);
$totalRows_salesmen = mysql_num_rows($salesmen);
// query edit
mysql_select_db($database_con_gl, $con_gl);
$query_edit = "SELECT * FROM gl_rtrans WHERE no_ref = '$_GET[noreferensi]'";
$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);
$totalRows_edit = mysql_num_rows($edit);
// get transaksi
mysql_select_db($database_con_gl, $con_gl);
$query_tr = "SELECT gl_trans.id, gl_trans.total, gl_trans.jumlah, gl_trans.hargasatuan, gl_trans.transaksi, gl_trans.diskon, gl_akun.akun, gl_akun.id as akun_id, gl_barang.id as brg_id, gl_barang.barang, gl_trans.kendaraan, gl_satuan.satuan FROM gl_trans, gl_akun, gl_barang, gl_satuan WHERE gl_akun.id = gl_trans.akun AND gl_barang.id = gl_trans.barang AND gl_satuan.id = gl_trans.satuan AND gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.pos='K' ORDER BY gl_trans.id desc";
$tr = mysql_query($query_tr, $con_gl) or die(mysql_error());
$row_tr = mysql_fetch_assoc($tr);
$totalRows_tr = mysql_num_rows($tr);
// get biaya
mysql_select_db($database_con_gl, $con_gl);
$query_getbiaya = "SELECT distinct gl_rtrans.akbiaya, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun=gl_rtrans.akbiaya";
$getbiaya = mysql_query($query_getbiaya, $con_gl) or die(mysql_error());
$row_getbiaya = mysql_fetch_assoc($getbiaya);
$totalRows_getbiaya = mysql_num_rows($getbiaya);
// get pajak
mysql_select_db($database_con_gl, $con_gl);
$query_getpajak = "SELECT distinct gl_rtrans.akpjk, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun=gl_rtrans.akpjk";
$getpajak = mysql_query($query_getpajak, $con_gl) or die(mysql_error());
$row_getpajak = mysql_fetch_assoc($getpajak);
$totalRows_getpajak = mysql_num_rows($getpajak);
// get kendaraan
mysql_select_db($database_con_gl, $con_gl);
$query_kend = "select a.jenis, b.nopol, b.tipe from gl_jkendaraan a ,gl_kendaraan b, gl_jenbar c where a.id = b.jenis AND c.barang='$row_tr[brg_id]' AND a.id = c.jenis AND b.tersedia='1' order by a.jenis, b.nopol";
$kend       = mysql_query($query_kend, $con_gl) or die(mysql_error());
$row_kend   = mysql_fetch_assoc($kend);
$total_kend = mysql_num_rows($kend);
// get piutang
mysql_select_db($database_con_gl, $con_gl);
$query_getidh = "SELECT gl_trans.id, gl_trans.akun, gl_trans.total FROM gl_trans WHERE gl_trans.no_ref='$_REQUEST[noreferensi]' AND gl_trans.transaksi LIKE '%%Piutang%%'";
$getidh = mysql_query($query_getidh, $con_gl) or die(mysql_error());
$row_getidh = mysql_fetch_assoc($getidh);
$totalRows_getidh = mysql_num_rows($getidh);
// get biaya
mysql_select_db($database_con_gl, $con_gl);
$query_getbiaya = "SELECT distinct gl_rtrans.akbiaya, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun=gl_rtrans.akbiaya";
$getbiaya = mysql_query($query_getbiaya, $con_gl) or die(mysql_error());
$row_getbiaya = mysql_fetch_assoc($getbiaya);
$totalRows_getbiaya = mysql_num_rows($getbiaya);
// get pajak
mysql_select_db($database_con_gl, $con_gl);
$query_getpajak = "SELECT distinct gl_rtrans.akpjk, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun=gl_rtrans.akpjk";
$getpajak = mysql_query($query_getpajak, $con_gl) or die(mysql_error());
$row_getpajak = mysql_fetch_assoc($getpajak);
$totalRows_getpajak = mysql_num_rows($getpajak);
?>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<style>
#cusinfo tr td {
	font-size:10px;	
}
</style>
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : ''
          });
      });
	  
</script>
<script type="text/javascript" src="js/ajax_data.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#edit').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Edit Transaksi Order</h1>
<div id="divDetail"><table width="100%" border="0" cellspacing="0" cellpadding="4" class="datatable" id="cusinfo">
  <tr>
    <th colspan="4" align="center">INFORMASI PELANGGAN</th>
  </tr>
  <tr>
    <td align="right" valign="top" style="background:#FFF;"><div align="left">INFO PEMESAN </div></td>
    <td width="33%" valign="top" style="background:#FFF;">&nbsp;</td>
    <td valign="top" style="background:#FFF;">INFO PENJAMIN </td>
    <td width="31%" valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top" style="background:#FFF;">NPWP :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td width="16%" align="right" valign="top" style="background:#FFF;">Nama :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
  <tr>
    <td width="20%" align="right" valign="top" style="background:#FFF;">Nama :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td align="right" valign="top" style="background:#FFF;">Alamat :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top" style="background:#FFF;">Alamat :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td align="right" valign="top" style="background:#FFF;">No. Tlp :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top" style="background:#FFF;">No. Tlp :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td align="right" valign="top" style="background:#FFF;">Jabatan : </td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top" style="background:#FFF;">Email :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
  
  <tr>
    <td align="right" valign="top" style="background:#FFF;">Keterangan :</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
    <td valign="top" style="background:#FFF;">&nbsp;</td>
  </tr>
</table>
</div>
<form action="proses/sretail.php?act=edit" method="POST" name="edit" id="edit" >
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr>
      <th colspan="2">Tanggal Reservasi </th>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <th colspan="2">Rincian Biaya Sewa Kendaraan </th>
    </tr>
    <tr>
      <td width="15%" align="right" valign="top" bgcolor="#FFFFFF">No Order *: </td>
      <td width="33%" valign="top" bgcolor="#FFFFFF"><div id="refDiv">
        <label>
          <input name="noreferensi" type="text" id="noreferensi" value="<?php echo $row_edit['no_ref']; ?>" size="20" maxlength="20" onchange="cekReferensis(this.value);" onfocus="this.blur();"/>
        </label>
      </div></td>
      <td width="4%" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td width="20%" align="right" valign="top"> Diskon 
        <input name="diskon" type="text" id="diskon" onchange="javascript:this.form.hargasatuan.value=this.form.hargasatuan.value - (this.form.hargasatuan.value * this.form.diskon.value / 100);" value="<?php echo $row_tr['diskon'];?>" size="2" maxlength="3"/>
%- Harga Rp.: </td>
      <td valign="top" bgcolor="#FFFFFF"><label></label>
        <label id="divHargaKendaraan">
          <input name="hargasatuan" type="text" id="hargasatuan" onchange="javascript:this.form.total.value=(this.form.jumlah.value * this.form.hargasatuan.value) - (this.form.jumlah.value * this.form.hargasatuan.value * this.form.diskon.value / 100);" value="<?php echo $row_tr['hargasatuan'] * $row_tr['jumlah'] - ($row_tr['diskon']*($row_tr['hargasatuan']*$row_tr['jumlah']) / 100);?>" size="10" maxlength="10"/>
          <input name="xharga" type="hidden" id="xharga" value="<?php echo $row_tr['hargasatuan'];?>" />
        </label></td>
    </tr>
    <tr valign="top">
      <td align="right" valign="top" bgcolor="#FFFFFF">Tanggal Order *: </td>
      <td valign="top" bgcolor="#FFFFFF"><label>
        <input name="tanggal" type="text" class="calendar" id="tanggal" value="<?php echo $row_edit['tgl']; ?>" size="20" maxlength="15"/>
      </label>
        &nbsp;JT :
        <label>
          <input name="jatuhtempo" type="text" class="calendar" id="jatuhtempo" value="<?php echo $row_edit['jatuhtempo']; ?>" size="20" maxlength="15"/>
        </label></td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">BBM Rp.: </td>
      <td valign="top" bgcolor="#FFFFFF"><label id="divBBM">
      <input name="bbm" type="text" id="bbm" value="<?php echo $row_edit['bbm'];?>" size="10" maxlength="10" onchange="javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value"/>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" valign="top" bgcolor="#FFFFFF">Lokasi Kantor :</td>
      <td valign="top" class="datatable"><select name="gudang" id="gudang" style="width:180px;">
        <?php

do {  

?>
        <option value="<?php echo $row_gudang['id']?>"><?php echo $row_gudang['gudang']?></option>
        <?php

} while ($row_gudang = mysql_fetch_assoc($gudang));

  $rows = mysql_num_rows($gudang);

  if($rows > 0) {

      mysql_data_seek($gudang, 0);

	  $row_gudang = mysql_fetch_assoc($gudang);

  }

?>
      </select></td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">Tol  Rp.: </td>
      <td valign="top" bgcolor="#FFFFFF"><label id="divTol">
      <input name="tol" type="text" id="tol" value="<?php echo $row_edit['tol'];?>" size="10" maxlength="10" onchange="javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value"/>
      </label></td>
    </tr>
    <tr valign="top">
      <td width="15%" align="right" valign="top" bgcolor="#FFFFFF">Nama Pelanggan *:</td>
      <td width="33%" valign="top" bgcolor="#FFFFFF">
	  <!--
	  <label>
        <input name="qtxt" type="text" id="qtxt" value="Cari Nama/No. Telp ..." size="23" maxlength="100" onclick="this.value='';" onkeypress="browseKontak('Customer');"/>
      </label>
        <label id="divKontak">
          <select name="dari" id="dari" onchange="setKeterangan(this.value);getDetailCustomer(this.value);" style="width:150px;">
            <option value="" <?php if (!(strcmp("", $row_edit['kontak']))) {echo "selected=\"selected\"";} ?>>Pilih Customer</option>
            <?php
			do {  
			?>
						<option value="<?php echo $row_kontak['id']?>" <?php if($row_edit['kontak']==$row_kontak['id']) { ?>selected="selected"<?php } ?>><?php echo $row_kontak['nama']?></option>
						<?php
			} while ($row_kontak = mysql_fetch_assoc($kontak));
			  $rows = mysql_num_rows($kontak);
			  if($rows > 0) {
				  mysql_data_seek($kontak, 0);
				  $row_kontak = mysql_fetch_assoc($kontak);
			  }
			?>
          </select>
        </label>
		-->
		<!-- Added by suwondo -->
	  <input type="hidden" name="dari" id="dari" value="<?php echo $row_edit['kontak']; ?>" />
	  <?php list($kontak) = mysql_fetch_row(mysql_query("select nama from gl_kontak where id = '$row_edit[kontak]'"));?>
	  <input type="text" name="qtxt" id="qtxt" value="<?php echo $kontak; ?>" placeholder="Cari Customer ..." size="30" readonly style="background-color:#fff;border:1px solid #999; height:16px;" onclick="NewWindow('index.php?component=kontak&amp;task=list&amp;ref=Customer&amp;open=window','name','825','450','yes');return false" /><script>window.getDetailCustomer('<?php echo $row_edit['kontak']; ?>');window.setKeterangan('<?php echo $row_edit['kontak']; ?>')</script>
		</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">Parkir Rp.:</td>
      <td valign="top" bgcolor="#FFFFFF"><label id="divParkir">
      <input name="parkir" type="text" id="parkir" value="<?php echo $row_edit['parkir'];?>" size="10" maxlength="10" onchange="javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value"/>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" valign="top" bgcolor="#FFFFFF">Paket Sewa *: </td>
      <td valign="top" bgcolor="#FFFFFF">
	  <!--
	  <label>
        <select name="barang" id="barang" style="width:180px;" onchange="getListKendaraan();">
          <?php
		do {  
		mysql_select_db($database_con_gl, $con_gl);
		$query_getpro = "SELECT id, barang, keterangan FROM gl_barang where kelompok='$row_kelom[id]' order by barang";
		$getpro = mysql_query($query_getpro, $con_gl) or die(mysql_error());
		$row_getpro = mysql_fetch_assoc($getpro);
		$totalRows_getpro = mysql_num_rows($getpro);
		?>
				  <?php
		 if($totalRows_getpro  > 0) { ?>
				  <option value="" style="background:#DDDDDD;font-weight:bold;"><?php echo $row_kelom['kelompok']?></option>
				  <?php do { ?>
				  <option value="<?php echo $row_getpro['id']; ?>" title="<?php echo $row_getpro['keterangan']; ?>" <?php if($row_tr['brg_id']==$row_getpro['id']) { ?>selected="selected"<?php } ?>> - <?php echo $row_getpro['barang']; ?></option>
				  <?php }  while ($row_getpro = mysql_fetch_assoc($getpro)); ?>
				  <?php } ?>
				  <?php
		} while ($row_kelom = mysql_fetch_assoc($kelom));
		  $rows = mysql_num_rows($kelom);
		  if($rows > 0) {
			  mysql_data_seek($kelom, 0);
			  $row_kelom = mysql_fetch_assoc($kelom);
		  }
		?>
        </select>
      </label>
	  -->
	  <!-- Added by suwondo -->
	  <input type="hidden" name="barang" id="barang" value="<?php echo $row_tr['brg_id']; ?>" />
	  <?php list($barang) = mysql_fetch_row(mysql_query("SELECT barang FROM gl_barang where kelompok='$row_kelom[id]' and id = '$row_tr[brg_id]' "));?>
	  <input type="text" name="txtbarang" id="txtbarang" value="<?php echo $barang; ?>" placeholder="Cari Paket Sewa ..." size="40" readonly style="background-color:#fff;border:1px solid #999; height:16px;" onclick="NewWindow('index.php?component=barang&amp;task=list&amp;kelompok=<?php echo $row_kelom['id']; ?>&amp;open=window','name','825','450','yes');return false" />
	  </td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">Jasa Supir Rp.: </td>
      <td valign="top" bgcolor="#FFFFFF"><label id="divSupir">
      <input name="supir" type="text" id="supir" value="<?php echo $row_edit['supir'];?>" size="10" maxlength="10" onchange="javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value"/>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" valign="top" bgcolor="#FFFFFF">Kendaraan *: </td>
      <td valign="top" bgcolor="#FFFFFF">
		<!--
		<label id="divListKendaraan">
        <select name="kendaraan" id="kendaraan" style="width:180px;" onChange="getHargaKendaraan();getBiayaBBM();getBiayaTol();getBiayaParkir();getBiayaSupir();getBiayaAkomodasi();getBiayaOther();">
          <?php if($total_kend > 0) { do { ?>
          <option value="<?php echo $row_kend['nopol'];?>" <?php if($row_tr['kendaraan']==$row_kend['nopol']) { ?>selected="selected"<?php } ?>><?php echo $row_kend['jenis'];?>-<?php echo $row_kend['tipe'];?> ( <?php echo $row_kend['nopol'];?> )</option>
		  <?php }while($row_kend = mysql_fetch_assoc($kend)); } ?>
        </select>
      </label> -->
	  <!-- Added by suwondo -->
	  <input type="hidden" name="kendaraan" id="kendaraan" value="<?php echo $row_tr['kendaraan']; ?>" />
	  <?php
	  list($kendaraaan, $nopolisi) = mysql_fetch_row(mysql_query("select a.tipekendaraan, b.nopolisi from gl_tipekendaraan as a inner join gl_masterkendaraan as b on (a.id = b.tipekendaraan) inner join gl_jenbar as c on (a.id = c.jenis) where c.barang='$row_tr[brg_id]' and b.nopolisi = '$row_tr[kendaraan]' AND b.tersedia='1'"));
	  ?>
	  <input type="text" name="txtkendaraan" id="txtkendaraan" value="<?php echo $kendaraaan." (".$nopolisi.")"; ?>" placeholder="Cari Kendaraan ..." size="40" readonly style="background-color:#fff;border:1px solid #999; height:16px;" onclick="NewWindow('index.php?component=kendaraan&amp;task=list&amp;barang='+document.getElementById('barang').value+'&amp;open=window','name','825','450','yes');return false" />
	  </td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">Uang Makan Rp.: </td>
      <td valign="top" bgcolor="#FFFFFF"><label id="divAkomodasi">
      <input name="akomodasi" type="text" id="akomodasi" value="<?php echo $row_edit['akomod'];?>" size="10" maxlength="10" onchange="javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value"/>
      </label></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Tanggal Pemakaian : </td>
      <td valign="top" bgcolor="#FFFFFF"><label>
        <input name="checkin" type="text" class="calendar" id="checkin" value="<?php echo $row_edit['checkin'];?>" size="20" maxlength="15"/>
      </label>
        Jam :
  <label>
    <input name="waktucheckin" type="text" class="jam" id="waktucheckin" value="<?php echo $row_edit['waktucheckin'];?>" size="5" maxlength="5"/>
</label></td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">Biaya lain-lain Rp.: </td>
      <td valign="top" bgcolor="#FFFFFF"><label id="divOther">
      <input name="other" type="text" id="other" value="<?php echo $row_edit['other'];?>" size="10" maxlength="10" onchange="javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value"/>
      </label></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Lama Sewa :</td>
      <td valign="top" bgcolor="#FFFFFF"><label>
        <input name="jumlah" type="text" id="jumlah" onchange="getHargaKendaraan();getBiayaOprs();" value="<?php echo $row_tr['jumlah']; ?>" size="3" maxlength="5"/>
      </label>
        ( Jlmh Hari ) / 
        <input name="jmlhwkt" type="text" id="jmlhwkt" value="<?php echo $row_tr['jlhwkt']; ?>" size="3" maxlength="5"/>
(Jmlh Jam)</td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <th align="right" valign="top">Total Biaya : </th>
      <td valign="top" bgcolor="#FFFFFF"><label>
      <input name="biaya" type="text" id="biaya" value="<?php echo $row_getbiaya['total']; ?>" size="10" maxlength="10" onchange="javascript:this.form.ntotal.value = (2*this.form.xntotal.value) - this.form.xntotal.value + (2*this.form.biaya.value) - this.form.biaya.value + (2*this.form.pajak.value) - this.form.pajak.value;this.form.saldohutang.value=this.form.ntotal.value-this.form.bayar.value;" onfocus="this.blur();"/>
      </label>
        <!--<label>
          <input name="checkbox" type="checkbox" id="checkbox" onclick="if(this.checked) { javascript:this.form.biaya.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value; this.form.ntotal.value = (2*this.form.supir.value) - this.form.supir.value + (2*this.form.bbm.value) - this.form.bbm.value + (2*this.form.tol.value) - this.form.tol.value + (2*this.form.parkir.value) - this.form.parkir.value + (2*this.form.akomodasi.value) - this.form.akomodasi.value + (2*this.form.other.value) - this.form.other.value + (2*this.form.hargasatuan.value) - this.form.hargasatuan.value}" checked="checked"/>
        </label>
        <small>Hitung Total Biaya</small>--></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Tanggal Kembali :</td>
      <td valign="top" bgcolor="#FFFFFF"><label>
        <input name="checkout" type="text" class="calendar" id="checkout" value="<?php echo $row_edit['checkout'];?>" size="20" maxlength="15"/>
      </label>
        Jam :
  <label>
    <input name="waktucheckout" type="text" class="jam" id="waktucheckout" value="<?php echo $row_edit['waktucheckout'];?>" size="5" maxlength="5"/>
</label></td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top">PPN 
        <input name="bobot" type="text" id="bobot" value="<?php echo $row_getpajak['total'] / ($row_tr['hargasatuan'] * $row_tr['jumlah'] - ($row_tr['diskon']*($row_tr['hargasatuan']*$row_tr['jumlah']) / 100)) * 100;?>" size="3" maxlength="3" onchange="javascript:this.form.pajak.value = (this.form.hargasatuan.value * this.form.bobot.value) / 100;this.form.ntotal.value = (2*this.form.hargasatuan.value) - this.form.hargasatuan.value + (2*this.form.pajak.value) - this.form.pajak.value + (2*this.form.biaya.value) - this.form.biaya.value;"/>
%        :</td>
      <td valign="top" bgcolor="#FFFFFF"><input name="pajak" type="text" id="pajak" value="<?php echo $row_getpajak['total']; ?>" size="15" maxlength="100" onfocus="this.blur();"/></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Salesman :</td>
      <td valign="top" bgcolor="#FFFFFF"><label>
        <select name="recipient" id="recipient" style="width:180px;">
          <?php

do {  

?>
          <option value="<?php echo $row_salesmen['id'];?>" <?php if($_session[kontakid] == $row_salesmen['id']) { ?>selected="selected"<?php } ?>><?php echo $row_salesmen['nama']?></option>
          <?php

} while ($row_salesmen = mysql_fetch_assoc($salesmen));

  $rows = mysql_num_rows($salesmen);

  if($rows > 0) {

      mysql_data_seek($salesmen, 0);

	  $row_salesmen = mysql_fetch_assoc($salesmen);

  }

?>
        </select>
      </label></td>
      <td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
      <th align="right" valign="top">Total :</th>
      <td valign="top"><label>
      <input name="ntotal" type="text" id="ntotal" value="<?php $subt = intval($row_tr['hargasatuan'] * $row_tr['jumlah'] - ($row_tr['diskon']*($row_tr['hargasatuan']*$row_tr['jumlah']) / 100) + $row_getbiaya[total] + $row_getpajak[total]); echo $subt;?>" size="10" maxlength="10" onfocus="this.blur();"/>
      </label>
        <input name="akunkredit" type="hidden" id="akunkredit" value="<?php echo $row_def_ak['a_piu'];?>" />
        <input name="akunbiaya" type="hidden" id="akunbiaya" value="<?php echo $row_def_ak['a_beb'];?>" />
        <input name="akunpajak" type="hidden" id="akunpajak" value="<?php echo $row_def_ak['a_paj'];?>" />
        <input name="jenis" type="hidden" id="jenis" value="7" /></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Detail Transaksi :</td>
      <td bgcolor="#FFFFFF"><label>
        <textarea name="transaksi" cols="35" rows="2" id="transaksi"><?php echo $row_tr['transaksi']; ?></textarea>
      </label></td>
      <td align="right">&nbsp;</td>
      <td align="right">Keterangan :</td>
      <td><div id="divKeterangan">
        <textarea name="keterangan" cols="40" rows="2" id="keterangan"><?php echo $row_edit['keterangan']; ?></textarea>
        <input name="cid" type="hidden" id="cid" value=""/>
      </div></td>
    </tr>
    <tr>
      <td align="left" bgcolor="#FFFFFF"><input name="id_hutang" type="hidden" id="id_hutang" value="<?php echo $row_getidh['id']; ?>" />
        <input name="id_biaya" type="hidden" id="id_biaya" value="<?php echo $row_getbiaya['id']; ?>" />

        <input name="idpajak" type="hidden" id="idpajak" value="<?php echo $row_getpajak['id']; ?>" />
        <input name="id_transaksi" type="hidden" id="id_transaksi" value="<?php echo $row_tr['id'];?>" /></td>
      <td bgcolor="#FFFFFF"><input name="Save" type="submit" id="Save" value="Simpan Order" />
      <input name="Cancel" type="button" id="Cancel" value="Batal" onclick="javascript:history.go(-1);"/></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td colspan="2" align="center" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  </table>
</form>